Skip to content

Event Notification DA Fully configurable #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025
Merged

Conversation

whoffler
Copy link
Contributor

@whoffler whoffler commented Mar 4, 2025

Description

for issue - https://github.ibm.com/GoldenEye/issues/issues/12573

Event Notification DA Fully configurable flavor

Release required?

  • No release
  • Patch release (x.x.X)
  • Minor release (x.X.x)
  • Major release (X.x.x)
Release notes content

Run the pipeline

If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.

Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:

/run pipeline

Checklist for reviewers

  • If relevant, a test for the change is included or updated with this PR.
  • If relevant, documentation for the change is included or updated with this PR.

For mergers

  • Use a conventional commit message to set the release level. Follow the guidelines.
  • Include information that users need to know about the PR in the commit message. The commit message becomes part of the GitHub release notes.
  • Use the Squash and merge option.

@whoffler whoffler force-pushed the flexibleVariation branch 4 times, most recently from fd9cef1 to 5c55830 Compare March 5, 2025 11:57
@ocofaigh ocofaigh mentioned this pull request Mar 11, 2025
6 tasks
@ocofaigh
Copy link
Contributor

ocofaigh commented Mar 11, 2025

@whoffler Vipin has a PR open to update the current standard variation with some best practises. Since that variation is going away, can I suggest we just make the changes directly in this PR in the new variation you are adding?

@whoffler whoffler changed the title Event Notification DA Fully configurable - Work In Progress Event Notification DA Fully configurable Mar 13, 2025
Copy link
Contributor

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left an initial first round of comments to address - there will be more. Also we need to claify if we really should be using cloud_object_storage and key_management_service in our input names, as opposed to just cos and kms. Discussion started on slack

@@ -0,0 +1,14 @@
terraform {
required_version = ">= 1.3.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you update to >= 1.9.0 so we can use the terraform 1.9 cross variable validation feature.
We will need to use it in many input variables in variables.tf. For an idea of how to use it, see my branch (WIP): https://github.com/terraform-ibm-modules/terraform-ibm-scc/blob/DA/solutions/fully-configurable/variables.tf

@whoffler whoffler force-pushed the flexibleVariation branch 2 times, most recently from abeb33c to dcf9464 Compare March 20, 2025 09:08
@whoffler whoffler requested a review from ocofaigh March 20, 2025 09:25
@whoffler whoffler force-pushed the flexibleVariation branch from 29995b7 to 8d7f1f9 Compare March 20, 2025 11:04
Copy link
Contributor

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whoffler still a lot of things to address here. Its not consistent at all with the SCC DA. Please review your variable descriptions, variable validation and other logic to ensure consistency. Some other things that stand out:

Copy link
Contributor

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whoffler Also take a look at terraform-ibm-modules/terraform-ibm-secrets-manager#309 - we will need something similar in this PR

@whoffler
Copy link
Contributor Author

@ocofaigh

was going to do that in a separate PR but will add here instead

@ocofaigh
Copy link
Contributor

@whoffler A separate Pr is fine if you want - but just remove the security-enforced code from this PR then

@whoffler whoffler force-pushed the flexibleVariation branch 2 times, most recently from 71ea249 to b3f69cf Compare March 27, 2025 10:42
@rajatagarwal-ibm rajatagarwal-ibm marked this pull request as ready for review April 11, 2025 16:19
@rajatagarwal-ibm
Copy link
Member

/run pipeline

4 similar comments
@rajatagarwal-ibm
Copy link
Member

/run pipeline

@rajatagarwal-ibm
Copy link
Member

/run pipeline

@rajatagarwal-ibm
Copy link
Member

/run pipeline

@rajatagarwal-ibm
Copy link
Member

/run pipeline

@whoffler
Copy link
Contributor Author

whoffler commented May 6, 2025

/run pipeline

@whoffler whoffler force-pushed the flexibleVariation branch from 248f729 to fab02f3 Compare May 6, 2025 12:51
@whoffler
Copy link
Contributor Author

whoffler commented May 6, 2025

/run pipeline

@whoffler whoffler force-pushed the flexibleVariation branch from fab02f3 to 2448f91 Compare May 6, 2025 14:19
@whoffler
Copy link
Contributor Author

whoffler commented May 6, 2025

/run pipeline

1 similar comment
@whoffler
Copy link
Contributor Author

whoffler commented May 6, 2025

/run pipeline

@whoffler whoffler force-pushed the flexibleVariation branch from 2448f91 to f8e1e47 Compare May 7, 2025 13:12
@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

2 similar comments
@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

@whoffler whoffler force-pushed the flexibleVariation branch from f8e1e47 to 09fd83d Compare May 7, 2025 15:17
@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

1 similar comment
@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

akocbek
akocbek previously requested changes May 7, 2025
Copy link
Contributor

@akocbek akocbek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in main variables.tf we have


variable "kms_encryption_enabled" {
  type        = bool
  description = "Set to `true` to control the encryption keys that are used to encrypt the data that you store in the Event Notifications instance. If set to `false`, the data is encrypted by using randomly generated keys. For more information, see [Managing encryption](https://cloud.ibm.com/docs/event-notifications?topic=event-notifications-en-managing-encryption)."
  default     = false
  validation {
    condition     = var.kms_encryption_enabled == false || var.plan == "standard"
    error_message = "kms encryption is only supported for standard plan"
  }
}


When `existing_en_instance_crn` is not passed, this solution configures the following infrastructure:

- optionally a KMS key ring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what defines optionally (what inputs define if it is optional or not)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a user sets kms_encryption_enabled to true and provides an existing KMS instance then a KMS key ring will be created


When `existing_en_instance_crn` is passed, this solution ignores ALL other inputs and sets the outputs based on the CRN.

- required inputs MUST still be set, but will be ignored.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of setting required inputs if they are ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think this is no longer true, will remove

create_cross_account_en_kms_auth_policy = var.existing_en_instance_crn == null && !var.skip_en_kms_auth_policy && var.ibmcloud_kms_api_key != null
# Create cross account COS / KMS auth policy if not using existing EN instance, if not using existing bucket, if 'skip_cos_kms_auth_policy' is false, and if a value is passed for 'ibmcloud_kms_api_key'
create_cross_account_cos_kms_auth_policy = var.existing_en_instance_crn == null && var.existing_cos_bucket_name == null && !var.skip_cos_kms_auth_policy && var.ibmcloud_kms_api_key != null
kms_region = var.kms_encryption_enabled ? var.existing_kms_instance_crn != null ? module.existing_kms_crn_parser[0].region : var.existing_kms_root_key_crn != null ? module.existing_kms_key_crn_parser[0].region : null : null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are quite difficult to read.

could we improve it as the following (must be tested out)

kms_crn_parser = var.kms_encryption_enabled && (
    var.existing_kms_instance_crn != null ? module.existing_kms_crn_parser[0] :
    var.existing_kms_root_key_crn != null ? module.existing_kms_key_crn_parser[0] :
    null
  )


kms_region = local.kms_crn_parser != null ? local.kms_crn_parser.region : null
existing_kms_guid = local.kms_crn_parser != null ? local.kms_crn_parser.service_instance : null
kms_service_name = local.kms_crn_parser != null ? local.kms_crn_parser.service_name : null
kms_account_id = local.kms_crn_parser != null ? local.kms_crn_parser.account_id : null
en_kms_key_id = local.create_kms_keys ? module.kms[0].keys[format("%s.%s", local.en_key_ring_name, local.en_key_name)].key_id :
                var.existing_kms_root_key_crn != null ? module.existing_kms_key_crn_parser[0].resource : null
existing_kms_instance_crn = var.kms_encryption_enabled ? 
  (var.existing_kms_instance_crn != null ? var.existing_kms_instance_crn :
    format("crn:v1:bluemix:%s:%s:%s:%s:%s::", 
           module.existing_kms_key_crn_parser[0].ctype,
           module.existing_kms_key_crn_parser[0].service_name,
           module.existing_kms_key_crn_parser[0].region,
           module.existing_kms_key_crn_parser[0].scope,
           module.existing_kms_key_crn_parser[0].service_instance)) :
  null

}

# If existing KMS root key CRN passed, parse details from it
module "kms_root_key_crn_parser" {
module "existing_kms_key_crn_parser" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check if var.kms_encryption_enabled is true as well, since we did it for existing_kms_crn_parser

on the other hand, do we even need to check for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we no longer need to check for this, removing

default = null
description = "The CRN of an IBM Cloud Monitoring instance used to monitor the IBM Cloud Object Storage bucket that is used for storing failed events. If no value passed, metrics are sent to the instance associated to the container's location unless otherwise specified in the Metrics Router service configuration. Ignored if using existing Object Storage bucket."
}

variable "prefix" {
type = string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we decided prefix definition. Please take a look

https://github.ibm.com/GoldenEye/issues/issues/13592#issuecomment-112076767

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix definition already in place?

condition = alltrue([
for tag in var.event_notifications_access_tags : can(regex("[\\w\\-_\\.]+:[\\w\\-_\\.]+", tag)) && length(tag) <= 128
])
error_message = "Tags must match the regular expression \"[\\w\\-_\\.]+:[\\w\\-_\\.]+\", see https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#limits for more details"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add explanation what regex mean? not sure if every consumer would understand regex.

}

variable "kms_endpoint_url" {
variable "existing_kms_root_key_crn" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can existing_kms_root_key_crn be passed (is taken into account) in a case that kms_encryption_enabled is disabled? should we add this into input validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added input validation in the kms_encryption_enabled variable

}
}

variable "existing_kms_root_key_crn" {
variable "kms_endpoint_url" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can kms_endpoint_url be passed (is taken into account) in a case that kms_encryption_enabled is disabled? should we add this into input validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added input validation in the kms_encryption_enabled variable

@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

3 similar comments
@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

@whoffler
Copy link
Contributor Author

whoffler commented May 7, 2025

/run pipeline

@ocofaigh
Copy link
Contributor

ocofaigh commented May 7, 2025

@whoffler Can you share the error your getting before re-running the pipeline each time so we can track the failures?

@whoffler
Copy link
Contributor Author

whoffler commented May 8, 2025

Sure, always getting the same error on different tests

summary: 'CreateIntegrationWithContext failed: Internal server error.'

@whoffler
Copy link
Contributor Author

whoffler commented May 8, 2025

/run pipeline

@ocofaigh ocofaigh merged commit 27121e7 into main May 8, 2025
2 checks passed
@ocofaigh ocofaigh deleted the flexibleVariation branch May 8, 2025 10:36
@terraform-ibm-modules-ops
Copy link
Contributor

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants